<template>
  <div class="app-container">
    <el-button type="primary" @click="GObACK">返回</el-button>
    <h2>会员昵称:{{ memberName }}</h2>
    <el-table v-loading="loading" :data="tableData">
      <el-table-column
        label="发生时间"
        align="center"
        prop="createTime"
        width="180"
        sortable="custom"
        :sort-orders="['descending', 'ascending']"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="事项类型" prop="matterType" />
      <el-table-column label="余额变动" prop="balanceChanges" />
      <el-table-column label="账户余额" prop="accountBalance">
        <template slot-scope="scope">
          {{ formatTableValue(scope.row.accountBalance) }}
        </template>
      </el-table-column>
      <el-table-column label="备注" prop="remark">
        <template slot-scope="scope">
          {{ formatTableValue(scope.row.remark) }}
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getMemberDetailsList } from "@/api/system/member";

export default {
  name: "UserManage",
  data() {
    return {
      loading: true,
      total: 0,
      tableData: [],
      queryParams: {
        pageNum: 1,
        pageSize: 15,
      },
      memberName: "",
    };
  },
  watch: {
    $route: {
      handler(newVal, oldVal) {
        this.getList();
        this.memberName = newVal.query.memberName;
      },
      immediate: true,
    },
  },
  methods: {
    getList() {
      this.loading = true;
      getMemberDetailsList({ memberId: this.$route.query.id }).then(
        (response) => {
          this.tableData = response.rows;
          this.total = response.total || 0;
          this.loading = false;
        }
      );
    },
    GObACK() {
      this.$router.push({ path: "/member/userManage" });
    },
  },
};
</script>
